
import unittest
import random

import helper.person as person
import helper.serialize_helper as serialize_helper

class TestSerialization(unittest.TestCase):
    
    def check_serialization(self,serializer):
        
        srcperson = person.Person(random.randint(1,100),"cheka")
        
        binimage = serializer.serialize(srcperson)
        
        cpyperson = serializer.deserialize(binimage)
        
        self.assertTrue(srcperson is not cpyperson)
        self.assertEqual(srcperson,cpyperson)
        
    def test_cpickle(self):
        self.check_serialization(serialize_helper.CPickleSerializer)
        
    def test_struct(self):
        self.check_serialization(person.StructPackSerializer)
        
if __name__ == "__main__":
    unittest.main()
        
        
        
        